package rua.jose.macamo;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.OverlayItem;

/**
 * mOverlayItem overrides the OvelayItem class and handles the location on the map
 * @author Panu Parviainen
 * @see com.google.android.maps.OverlayItem
 */

public class mOverlayItem extends OverlayItem implements Parcelable {
   private static final long serialVersionUID = 1L;
   protected String type, picture, minigametype, minigamedata;
   protected String address;

   /**
    * Constructs an mOVerlayItem
    * @param lat Latitude of the item
    * @param lon Longitude of the item
    * @param type Type of the item
    * @param name Name of the item
    * @param info Information about the item(location)
    * @param address Address of the item
    * @param picture Picture related to the item
    * @param minigametype What game of minigame is used for the item
    * @param minigamedata Data for the minigame
    */
   public mOverlayItem(int lat, int lon, String type, String name, String info,
         String address, String picture, String minigametype, String minigamedata) {
	   super(new GeoPoint(lat,lon), name, info);
	   this.address = address;
	   this.type = type;
	   this.picture = picture;	   
	   this.minigametype = minigametype;
	   this.minigamedata = minigamedata;
   }
   
   public int describeContents() {
      return 0;
  }

  @Override
  public void writeToParcel(Parcel out, int flags) {
     out.writeInt(this.mPoint.getLatitudeE6());
     out.writeInt(this.mPoint.getLongitudeE6());
     out.writeString(this.mTitle);
     out.writeString(this.mSnippet);
     out.writeString(this.type);
     out.writeString(this.address);
     out.writeString(this.picture);
     out.writeString(this.minigametype);
     out.writeString(this.minigamedata);
  }

  /**
   * Helper for creating Parcelable
   */
  public static final Parcelable.Creator<mOverlayItem> CREATOR
          = new Parcelable.Creator<mOverlayItem>() {
      public mOverlayItem createFromParcel(Parcel in) {
          return new mOverlayItem(in);
      }

      public mOverlayItem[] newArray(int size) {
          return new mOverlayItem[size];
      }
  };
  
  /**
   * Consturcts mOverlayItem from Parcel
   * @param in Parcel from which the mOverlayItem will be created
   */
  public mOverlayItem(Parcel in) {
     super(new GeoPoint(in.readInt(),in.readInt()),
           in.readString(),in.readString());
     this.type = in.readString();
     this.address = in.readString();
     this.picture = in.readString();
     this.minigametype = in.readString();
     this.minigamedata = in.readString();
  }

}//class

